package com;

import java.util.ArrayList;

/**
 * @author wlg
 */
public class Account {
    /**
     * 总额
     */
    private int balance = 0;
    /**
     * 明细类型的可变长列表
     */
    ArrayList<Detail> details = new ArrayList<>();

    /**
     * 显示功能列表
     */
    public void showWelcome() {
        System.out.println("---------------------家庭记账软件----------------------");
        System.out.println("                 1. 收支明细");
        System.out.println("                 2. 登记收入");
        System.out.println("                 3. 登记支出");
        System.out.println("                 4. 账户总额");
        System.out.println("                 5. 退\t出");
        System.out.println("--------------------------------------------------------");
    }

    public int getBalance() {
        return balance;
    }

    // 展示收支
    public void showDetails() {
        String detailTop = "收    支-----------------收支金额-----------------说    明\n";
        System.out.println(detailTop);
        for (Detail detail : details) {
            System.out.println(detail.getSelection() + "\t\t\t\t\t\t" + detail.getFee() + "\t\t\t\t\t" + detail.getIllustrate());
        }

    }

    // 收入
    public void balanceIn(int bcIn, String illstrate) {
        Detail dt = new Detail("收入", bcIn, illstrate);
        balance += bcIn;
        details.add(dt);
    }

    // 支出
    public void balanceOut(int bcOut, String illstrate) {
        Detail dt = new Detail("支出", bcOut, illstrate);
        balance -= bcOut;
        details.add(dt);
    }
}
